home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / batchut / bathints.zip / BH_09.DOC < prev    next >
Text File  |  1988-10-16  |  13KB  |  272 lines

  1.  
  2.                                   BAT-HINT # 9 
  3.  
  4. ************************************************************************** 
  5.  
  6. from the BATHINTS library... part of the BATPOWER CONFERENCE from: 
  7.  
  8.                          THE PAINFRAME OPUS/FIDO 261/1004 
  9.  
  10.                         Baltimore, Maryland 1-301-488-7461 
  11.  
  12. ************************************************************************** 
  13.  
  14.  
  15.                     Errorlevels, Scan Codes and the Keyboard
  16.  
  17.  
  18. Some programs assign a value to the DOS variable ERRORLEVEL.  Indeed, only
  19. a program can place a value for errorlevel in memory (though of course the
  20. ERRORLEVEL is altered when you restart your computer).  Do not confuse
  21. ERRORLEVEL with replaceable parameters or environmental variables, for it
  22. is neither.  Its value is stored in its own register and is only one byte
  23. in size.  The value of the ERRORLEVEL variable can be examined and tested
  24. with the IF and ERRORLEVEL subcommands in batch files... and since the
  25. variable is not altered with testing, repetitive tests can be performed. 
  26. Tests for errorlevels are always constructed from highest to lowest in
  27. batch files, since the statement:
  28.  
  29.     if errorlevel x {perform command}
  30.  
  31. is true if the errorlevel value "x" is equal to or greater than value "x". 
  32. Conversely, the statement:
  33.  
  34.     if not errorlevel x {perform command}
  35.  
  36. is true if the errorlevel is less than the value "x".  These two IF
  37. statements can be nested to test the value of ERRORLEVEL for a specific
  38. value as shown below:
  39.  
  40.     if errorlevel x if not errorlevel x+1 {perform command}
  41.  
  42. where "x" is any value from 0 to 254 and "x+1" is any value from 1 to 255
  43. when the if errorlevel statement is nested as shown above.
  44.  
  45. Very few DOS commands place a value in ERRORLEVEL (for example, BACKUP and
  46. RESTORE return 0 upon failure and 1 upon success), but several public
  47. domain and copywrited programs are available to make ERRORLEVEL testing
  48. useful to the user.  One such program available in BATPOWER files is
  49. KEY.COM.  Read the documentation file that accompanies KEY.COM for details
  50. on its use.  To assist in the use of KEY.COM, examine the table below:
  51.  
  52. Table 1.   The 256 Characters of the IBM Extended Character Set
  53.  
  54. ╔═══╤═══╦═══╤═══╦═══╤═══╦═══╤═══╦═══╤═══╦═══╤═══╦═══╤═══╦═══╤═══╗      
  55. ║000│nul║032│spc║064│ @ ║096│ ` ║128│ Ç ║160│ á ║192│ └ ║224│ α ║      
  56. ║001│soh║033│ ! ║065│ A ║097│ a ║129│ ü ║161│ í ║193│ ┴ ║225│ ß ║      
  57. ║002│stx║034│ " ║066│ B ║098│ b ║130│ é ║162│ ó ║194│ ┬ ║226│ Γ ║      
  58. ║003│etx║035│ # ║067│ C ║099│ c ║131│ â ║163│ ú ║195│ ├ ║227│ π ║      
  59. ║004│eot║036│ $ ║068│ D ║100│ d ║132│ ä ║164│ ñ ║196│ ─ ║228│ Σ ║      
  60. ║005│enq║037│ % ║069│ E ║101│ e ║133│ à ║165│ Ñ ║197│ ┼ ║229│ σ ║      
  61. ║006│ack║038│ & ║070│ F ║102│ f ║134│ å ║166│ ª ║198│ ╞ ║230│ µ ║      
  62. ║007│bel║039│ ' ║071│ G ║103│ g ║135│ ç ║167│ º ║199│ ╟ ║231│ τ ║      
  63. ║008│bs ║040│ ( ║072│ H ║104│ h ║136│ ê ║168│ ¿ ║200│ ╚ ║232│ Φ ║      
  64. ║009│tab║041│ ) ║073│ I ║105│ i ║137│ ë ║169│ ⌐ ║201│ ╔ ║233│ Θ ║      
  65. ║010│lf ║042│ * ║074│ J ║106│ j ║138│ è ║170│ ¬ ║202│ ╩ ║234│ Ω ║      
  66. ║011│vt ║043│ + ║075│ K ║107│ k ║139│ ï ║171│ ½ ║203│ ╦ ║235│ δ ║      
  67. ║012│ff ║044│ , ║076│ L ║108│ l ║140│ î ║172│ ¼ ║204│ ╠ ║236│ ∞ ║      
  68. ║013│ret║045│ - ║077│ M ║109│ m ║141│ ì ║173│ ¡ ║205│ ═ ║237│ φ ║      
  69. ║014│so ║046│ . ║078│ N ║110│ n ║142│ Ä ║174│ « ║206│ ╬ ║238│ ε ║      
  70. ║015│si ║047│ / ║079│ O ║111│ o ║143│ Å ║175│ » ║207│ ╧ ║239│ ∩ ║      
  71. ║016│dle║048│ 0 ║080│ P ║112│ p ║144│ É ║176│ ░ ║208│ ╨ ║240│ ≡ ║      
  72. ║017│dc1║049│ 1 ║081│ Q ║113│ q ║145│ æ ║177│ ▒ ║209│ ╤ ║241│ ± ║      
  73. ║018│dc2║050│ 2 ║082│ R ║114│ r ║146│ Æ ║178│ ▓ ║210│ ╥ ║242│ ≥ ║      
  74. ║019│dc3║051│ 3 ║083│ S ║115│ s ║147│ ô ║179│ │ ║211│ ╙ ║243│ ≤ ║      
  75. ║020│dc4║052│ 4 ║084│ T ║116│ t ║148│ ö ║180│ ┤ ║212│ ╘ ║244│ ⌠ ║      
  76. ║021│nak║053│ 5 ║085│ U ║117│ u ║149│ ò ║181│ ╡ ║213│ ╒ ║245│ ⌡ ║      
  77. ║022│syn║054│ 6 ║086│ V ║118│ v ║150│ û ║182│ ╢ ║214│ ╓ ║246│ ÷ ║      
  78. ║023│etb║055│ 7 ║087│ W ║119│ w ║151│ ù ║183│ ╖ ║215│ ╫ ║247│ ≈ ║      
  79. ║024│can║056│ 8 ║088│ X ║120│ x ║152│ ÿ ║184│ ╕ ║216│ ╪ ║248│ ° ║      
  80. ║025│em ║057│ 9 ║089│ Y ║121│ y ║153│ Ö ║185│ ╣ ║217│ ┘ ║249│ ∙ ║      
  81. ║026│sub║058│ : ║090│ Z ║122│ z ║154│ Ü ║186│ ║ ║218│ ┌ ║250│ · ║      
  82. ║027│esc║059│ ; ║091│ [ ║123│ { ║155│ ¢ ║187│ ╗ ║219│ █ ║251│ √ ║      
  83. ║028│fs ║060│ < ║092│ \ ║124│ | ║156│ £ ║188│ ╝ ║220│ ▄ ║252│ ⁿ ║      
  84. ║029│gs ║061│ = ║093│ ] ║125│ } ║157│ ¥ ║189│ ╜ ║221│ ▌ ║253│ ² ║      
  85. ║030│rs ║062│ > ║094│ ^ ║126│ ~ ║158│ ₧ ║190│ ╛ ║222│ ▐ ║254│ ■ ║      
  86. ║031│us ║063│ ? ║095│ _ ║127│  ║159│ ƒ ║191│ ┐ ║223│ ▀ ║255│   ║      
  87. ╚═══╧═══╩═══╧═══╩═══╧═══╩═══╧═══╩═══╧═══╩═══╧═══╩═══╧═══╩═══╧═══╝
  88.  
  89. The first 128 characters (0 to 127) are the standard ASCII character set
  90. and the last 128 characters (128 to 255) comprise the IBM extended
  91. character set.  The first 32 characters (0 to 31) are the control
  92. characters, explained in more detail in table 2.
  93.     
  94. Table 2.  The Control Characters
  95.     
  96. ╔═══╤══════╦═══╤══════╦═══╤══════╦═══╤══════╗
  97. ║000│ N/A  ║008│ctrl-h║016│ctrl-p║024│ctrl-x║
  98. ║001│ctrl-a║009│ctrl-i║017│ctrl-q║025│ctrl-y║
  99. ║002│ctrl-b║010│ctrl-j║018│ctrl-r║026│ctrl-z║
  100. ║003│ctrl-c║011│ctrl-k║019│ctrl-s║027│ctrl-[║
  101. ║004│ctrl-d║012│ctrl-l║020│ctrl-t║028│ctrl-\║
  102. ║005│ctrl-e║013│ctrl-m║021│ctrl-u║029│ctrl-]║
  103. ║006│ctrl-f║014│ctrl-n║022│ctrl-v║030│ctrl-^║
  104. ║007│ctrl-g║015│ctrl-o║023│ctrl-w║031│ctrl-_║
  105. ╚═══╧══════╩═══╧══════╩═══╧══════╩═══╧══════╝
  106.  
  107. Notice that ctrl-g (code 007) is the bell.  Entering the follwing statement
  108. ina batch file will cause the speaker to beep:
  109.  
  110. echo ctrl-g
  111.  
  112. The line above is entered by typing ECHO then leaving a space then holding
  113. down the ctrl key and pressing the letter g.  You can use this technique to
  114. place a beep in your batch files at discrete points of processing.
  115.  
  116. You should also note from tables 1 and 2 the codes for certain important
  117. keys: codes 28, 29, 30 and 31 are the right, left, up and down cursor
  118. control keys respectively; code 13 is a carriage return; code 8 is the
  119. backspace key; code 27 is the escape key.
  120.  
  121. Keyboard combinations like shift-F9, alt-J, and ctrl-F7 also have scan
  122. codes... as do all the possible key combinations.  Using KEY.COM or other
  123. programs, you could figure these codes out yourself... just as with the 256
  124. characters of the extended character set, but they are shown below for
  125. convenience.  Note that all of these extended codes are composed of two
  126. numbers, the first of which is always 0.
  127.  
  128. Table 3.  Codes for Function and Other Keys Used Alone or in
  129.           Combination with the ALT, CTRL or SHIFT Keys
  130.                      
  131. ╔═════╤═════╤═════╤═════╤═════╦═════╤═════╤═════╤═════╤═════╗
  132. ║ KEY │     │ ALT │CTRL │SHIFT║ KEY │     │ ALT │CTRL │SHIFT║
  133. ╠═════╪═════╪═════╪═════╪═════╬═════╪═════╪═════╪═════╪═════╣
  134. ║ TAB │  9  │     │     │0;15 ║  r  │ 82  │0;19 │  18 │ 114 ║
  135. ║  -  │ 45  │0;130│     │ 95  ║  s  │ 83  │0;31 │  19 │ 115 ║
  136. ║  0  │ 48  │0;129│     │ 41  ║  t  │ 84  │0;20 │  20 │ 116 ║
  137. ║  1  │ 49  │0;120│     │ 33  ║  u  │ 85  │0;22 │  21 │ 117 ║
  138. ║  2  │ 50  │0;121│     │ 64  ║  v  │ 86  │0;47 │  22 │ 118 ║
  139. ║  3  │ 51  │0;122│     │ 35  ║  w  │ 87  │0;17 │  23 │ 119 ║
  140. ║  4  │ 52  │0;123│     │ 36  ║  x  │ 88  │0;45 │  24 │ 120 ║
  141. ║  5  │ 53  │0;124│     │ 37  ║  y  │ 89  │0;21 │  25 │ 121 ║
  142. ║  6  │ 54  │0;125│     │ 94  ║  z  │ 90  │0;44 │  26 │ 122 ║
  143. ║  7  │ 55  │0;126│     │ 38  ║ F1  │0;59 │0;104│0;94 │0;84 ║
  144. ║  8  │ 56  │0;127│     │ 42  ║ F2  │0;60 │0;105│0;95 │0;85 ║
  145. ║  9  │ 57  │0;128│     │ 40  ║ F3  │0;61 │0;106│0;96 │0;86 ║
  146. ║  =  │ 61  │0;131│     │ 43  ║ F4  │0;62 │0;107│0;97 │0;87 ║
  147. ║  a  │ 65  │0;30 │  1  │ 97  ║ F5  │0;63 │0;108│0;98 │0;88 ║
  148. ║  b  │ 66  │0;48 │  2  │ 98  ║ F6  │0;64 │0;109│0;99 │0;89 ║
  149. ║  c  │ 67  │0;46 │  3  │ 99  ║ F7  │0;65 │0;110│0;100│0;90 ║
  150. ║  d  │ 68  │0;32 │  4  │ 100 ║ F8  │0;66 │0;111│0;101│0;91 ║
  151. ║  e  │ 69  │0;18 │  5  │ 101 ║ F9  │0;67 │0;112│0;102│0;92 ║
  152. ║  f  │ 70  │0;33 │  6  │ 102 ║ F10 │0;68 │0;113│0;103│0;93 ║
  153. ║  g  │ 71  │0;34 │  7  │ 103 ║HOME │0;71 │     │0;119│  55 ║
  154. ║  h  │ 72  │0;35 │  8  │ 104 ║ UP  │0;72 │     │